import keyboard
import pyautogui
from pyperclip import copy
from time import sleep
import random
import threading


def write_text(text):
	for i in text:
		duration = random.randrange(1,2)
		sleep(duration)
		copy(i)
		pyautogui.hotkey('ctrl', 'v')


def is_exit():
	while True:
		if keyboard.is_pressed('esc'):
			break

def main():
	pyautogui.hotkey('winleft', 'r')
	pyautogui.write('notepad', 0.1)
	pyautogui.press('enter')

	text = '陋室铭'
	write_text(text)
	sleep(0.5)
	pyautogui.press('enter')

	text = '    山不在高，有仙则名。水不在深，有龙则灵。斯是陋室，惟吾德馨。苔痕上阶绿，草色入帘青。谈笑有鸿儒，往来无白丁。可以调素琴，阅金经。无丝竹之乱耳，无案牍之劳形。南阳诸葛庐，西蜀子云亭。孔子云：何陋之有？'
	write_text(text)


if __name__ == '__main__':
	thread1 = threading.Thread(target=main)
	thread2 = threading.Thread(target=is_exit)
	thread1.daemon = True
	thread1.start()
	thread2.start()